/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nys.conci.backend.entidad;

import com.nys.conci.backend.servicio.ServicioParametros;
import com.nys.conci.base.BeanBase;
import com.nys.conci.base.excepcion.ExcepcionManager;
import com.nys.conci.base.utilitario.EtiquetasUtil;
import com.nys.conci.base.utilitario.JSFUtil;
import com.nys.conci.usuario.entidad.Usuario;
import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletResponse;
import org.primefaces.component.menuitem.MenuItem;
import org.primefaces.component.submenu.Submenu;
import org.primefaces.model.DefaultMenuModel;
import org.primefaces.model.MenuModel;

/**
 *
 * @author Yeudy10
 */
@Named
@SessionScoped
public class MenuControlador extends BeanBase implements Serializable {

    @Inject
    private Identidad identidad;
    private boolean menu_us;
    private boolean menu_ad;

    //<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
    //<<>><<>><<>><<>><<>><<>><<>>   Inicializar  <<>><<>><<>><<>><<>><<>><<>>
    //<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
    /**
     * Constructor
     */
    /**
     * Inicializador de PostConstruccion.
     */
    @Override
    @PostConstruct
    public void inicializarPost() {
        if (null == this.identidad) {//Se encuentra desconectado
            try {
                FacesContext context = FacesContext.getCurrentInstance();
                HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
                response.sendRedirect("/xhtml/plantillas/login.xhtml");
            } catch (IOException ex) {
                Logger.getLogger(MenuControlador.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            if (this.identidad.isLogueado()) {
                if (identidad.isMenu_admin()) {
                    menu_ad = true;
                    menu_us = false;
                } else {
                    menu_ad = false;
                    menu_us = true;
                }
            }

        }
    }

    //<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
    //<<>><<>><<>><<>><<>><<>><<>>  METODOS   <<>><<>><<>><<>><<>><<>><<>><<>>
    //<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
    //<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
    //<<>><<>><<>><<>><<>><<>>   GETS AND SETS    <<>><<>><<>><<>><<>><<>><<>>
    //<<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>>
    /**
     * @return the menu_us
     */
    public boolean isMenu_us() {
        return menu_us;
    }

    /**
     * @param menu_us the menu_us to set
     */
    public void setMenu_us(boolean menu_us) {
        this.menu_us = menu_us;
    }

    /**
     * @return the menu_ad
     */
    public boolean isMenu_ad() {
        return menu_ad;
    }

    /**
     * @param menu_ad the menu_ad to set
     */
    public void setMenu_ad(boolean menu_ad) {
        this.menu_ad = menu_ad;
    }
}